<template>
  <div class="side-panel">
    <div class="panel-header">
      <div class="title">常见问题</div>
      <icon-question-circle />
    </div>
    <div class="faq-list">
      <div
        v-for="(item, index) in faqItems"
        :key="index"
        class="faq-item"
        :data-index="index + 1"
        @click="handleFaqClick(item)"
      >
        {{ item.question }}
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { IconQuestionCircle } from '@arco-design/web-vue/es/icon';

interface FaqItem {
  question: string;
  answer: string;
}

const faqItems: FaqItem[] = [
  {
    question: '什么是AI智能？',
    answer: 'AI智能是指通过计算机程序模拟人类智能的技术...'
  },
  {
    question: '机器学习基础知识',
    answer: '机器学习是AI的一个重要分支...'
  },
  {
    question: '如何开始学习编程？',
    answer: '开始学习编程的最佳方式是...'
  },
  {
    question: 'Python vs JavaScript?',
    answer: 'Python和JavaScript是两种流行的编程语言...'
  }
];

const emit = defineEmits(['select']);

const handleFaqClick = (item: FaqItem) => {
  emit('select', item);
};
</script>

<style scoped lang="less">
.side-panel {
  width: 260px;
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);

  .panel-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
    background: #27348C;
    
    .title {
      font-size: 16px;
      font-weight: 500;
      color: #ffffff;
    }
  }

  .faq-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;

    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-thumb {
      background-color: var(--color-text-4);
      border-radius: 3px;
    }

    &::-webkit-scrollbar-track {
      background-color: var(--color-fill-2);
      border-radius: 3px;
    }
  }

  .faq-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--color-text-2);
    margin-bottom: 8px;
    transition: all 0.3s ease;
    background-color: #F7F8FA;
    position: relative;
    padding-left: 40px;

    &::before {
      content: attr(data-index);
      position: absolute;
      left: 12px;
      width: 20px;
      height: 20px;
      background-color: #E8EBF1;
      color: #27348C;
      border-radius: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 12px;
    }

    &:hover {
      background-color: #E8EBF1;
      transform: translateY(-1px);
    }
  }
}
</style> 